#!/usr/bin/env node

const pinyin = require("pinyin");
const os = require("os");
const exec = require('child_process').exec;

exec(os.platform() === 'darwin' ? 'pbpaste' : 'cat /dev/clipboard', function(err, stdout, stderr) {
    if (err) {
        return console.log('error:', stderr);
    }
    const list = pinyin(stdout.replace(/\s/g, ''), { style: pinyin.STYLE_FIRST_LETTER });
    let str = list.map(o=>o[0]).join('').toUpperCase();
    str = `TB_ZYZX_${str}`;

    exec(`printf ${str} ${os.platform() === 'darwin' ? '| pbcopy' : '> /dev/clipboard'}`, ()=>{
        console.log(str);
    });
});
